﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Data;
using DOTNETGROUP.Entities;
using System.Data;

public partial class Controls_ControlVideoContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Pager1.CurrentIndex = 1;
            HienThi_Video(Pager1.CurrentIndex);
        }
    }
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }


    protected void HienThi_Video(int pageNo)
    {
        int TotalRows = 0;
        DataSet dsVideo = DataRepository.Provider.ExecuteDataSet("Video_GetPaged", "", "NgayCapNhat DESC", pageNo - 1, Pager1.PageSize);
        dtlVideo.DataSource = dsVideo;
        dtlVideo.DataBind();

        // Hien thi tong so trang
        // Hien thi tong so trang
        try
        {
            TotalRows = Convert.ToInt32(dsVideo.Tables[1].Rows[0][0]);
        }
        catch (Exception)
        {
        }
        Pager1.ItemCount = TotalRows;
        if (TotalRows <= Pager1.PageSize)
            Pager1.Visible = false;
        else
            Pager1.Visible = true;
    }

    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
        Pager1.CurrentIndex = currnetPageIndex;
        HienThi_Video(currnetPageIndex);
    }

    public string GetLoaiVideo(object idLoaiVideo)
    {
        int id = Convert.ToInt32(idLoaiVideo.ToString());
        LoaiVideo ent_LoaiVideo = DataRepository.LoaiVideoProvider.GetById(id);
        return ent_LoaiVideo.TenLoaiVideo;
    }
}